package com.leyou.item.service.imp;

import com.leyou.item.mapper.ICategoryMapper;
import com.leyou.item.pojo.Category;
import com.leyou.item.service.ICategoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品分裂业务逻辑实现层
 */
@Service
public class CategoryServiceImpl implements ICategoryService {

    private static final Logger logger = LoggerFactory.getLogger(CategoryServiceImpl.class);

    @Autowired
    private ICategoryMapper categoryMapper;
    /**
     * 根据父节点id查询商品分类信息
     *
     * @param pid
     * @return
     */
    @Override
    public List<Category> findCategoryListByPid(Long pid) throws Exception {
        if(pid == null || pid.longValue() < 0){
            throw new RuntimeException("请求参数不合法");
        }
        Category category = new Category();
        category.setParentId(pid);
        return this.categoryMapper.select(category);
    }

}
